<?php
/*------------------------------------------------------------------------
 * otherController.class.php 
 *
 * 其它接口
 * 	
 * Created on 2015-11-29
 *
 * Author: hwc123 <hwc123@139.com>
 * 
 * Copyright (c) 2015 http://www.xm-news.com All rights reserved.
 * ------------------------------------------------------------------------
 */

namespace Api\Controller;
class OtherController extends CommonController{

	//获取类别列表接口
	public function get_category(){
		$module  = $this->_get('module', '', 'bank_name_list');

		$list = D('Category')->get_list($module);

		$data['list'] = $list?$list:array();

		if($list){
			$this->success('获取数据成功！', $data);
		}else{
			$this->success('找不到相关数据！', $data);
		}
	}
	//获取类别级别结构数据
	public function get_category_level_list(){
		$module  = $this->_get('module', '', 'shop_sort');

		$list = D('Category')->get_level_list($module);

		$data['list'] = $list ? $list : array();

		if($list){
			$this->success('获取数据成功！', $data);
		}else{
			$this->success('找不到相关数据！', $data);
		}
	}
	
	//检查更新
	public function check_update(){
		$where['client_type'] = $this->app_type;
		$where['status']      = 1;
		$field = 'file_id,download_url,content,version_name,version_code,update_date,is_force';
		$order = 'version_code desc';
		$info = D('AppVersions')->field($field)->where($where)->order($order)->find();

		//获取文件信息
		$download_url = D('File')->get_upload_filepath($info['file_id']);
		$info['download_url'] = $info['download_url'] ? $info['download_url'] : $download_url;
		$info['content']      = ($info['content']);
		$info['is_force']     = $info['is_force'] == 1;
		
		if($info['version_name']){
			$this->success('获取数据成功！', $info);
		}else{
			$this->success('已经是最新版本！');
		}
	}
}